Ext.define('SKJF.view.MASTER.v_mstsupplier', {
	extend: 'Ext.grid.Panel',
	requires: ['SKJF.store.s_mstsupplier'],
	
	title		: 'mstsupplier',
	itemId		: 'Listmstsupplier',
	alias       : 'widget.Listmstsupplier',
	store 		: 's_mstsupplier',
	columnLines : true,
	frame		: false,
	
	margin		: 0,
	selectedIndex : -1,
	
	initComponent: function(){		
		this.columns = [
			{
				header: 'KODE_SUPPLIER',filterable: true,
				dataIndex: 'KODE_SUPPLIER'
			},{
				header: 'NAMA_SUPPLIER',filterable: true,
				dataIndex: 'NAMA_SUPPLIER'
			},{
				header: 'CONTACT_PERSON',filterable: true,
				dataIndex: 'CONTACT_PERSON'
			},{
				header: 'BANK_ACCOUNT',filterable: true,
				dataIndex: 'BANK_ACCOUNT'
			},{
				header: 'ALAMAT_1',filterable: true,
				dataIndex: 'ALAMAT_1'
			},{
				header: 'KOTA_1',filterable: true,
				dataIndex: 'KOTA_1'
			},{
				header: 'NEGARA_1',filterable: true,
				dataIndex: 'NEGARA_1'
			},{
				header: 'ALAMAT_2',filterable: true,
				dataIndex: 'ALAMAT_2'
			},{
				header: 'KOTA_2',filterable: true,
				dataIndex: 'KOTA_2'
			},{
				header: 'NEGARA_2',filterable: true,
				dataIndex: 'NEGARA_2'
			},{
				header: 'TELPON',filterable: true,
				dataIndex: 'TELPON'
			},{
				header: 'FAX',filterable: true,
				dataIndex: 'FAX'
			},{
				header: 'EMAIL',filterable: true,
				dataIndex: 'EMAIL'
			}];
		this.features = [{
			ftype: 'filters',
			autoReload: true, //don't reload automatically
			encode: true, // json encode the filter query
			local: false
		}];
		this.dockedItems = [
			Ext.create('Ext.toolbar.Toolbar', {
				items: [{
					xtype: 'fieldcontainer',
					layout: 'hbox',
					defaultType: 'button',
					items: [{
						text	: 'Add',
						iconCls	: 'icon-add',
						action	: 'create'
					}, {
						xtype: 'splitter'
					}, {
						itemId	: 'btndelete',
						text	: 'Delete',
						iconCls	: 'icon-remove',
						action	: 'delete',
						disabled: true
					}]
				}, '-', {
					xtype: 'fieldcontainer',
					layout: 'hbox',
					defaultType: 'button',
					items: [{
						text	: 'Cetak',
						iconCls	: 'icon-print',
						action	: 'print'
					}]
				}]
			}),
			{
				xtype: 'pagingtoolbar',
				store: 's_mstsupplier',
				dock: 'bottom',
				displayInfo: true
			}
		];
		this.callParent(arguments);
		
		this.on('itemclick', this.gridSelection);
		this.getView().on('refresh', this.refreshSelection, this);
	},	
	
	gridSelection: function(me, record, item, index, e, eOpts){
		//me.getSelectionModel().select(index);
		this.selectedIndex = index;
		this.getView().saveScrollState();
	},
	
	refreshSelection: function() {
        this.getSelectionModel().select(this.selectedIndex);   /*Ext.defer(this.setScrollTop, 30, this, [this.getView().scrollState.top]);*/
    }

});